<template>
  <div class="list" ref="wrapper">
    <div>
      <div class="area">
        <div class="title area-color">当前城市</div>
        <div class="button-list">
          <div class="button-wrapper">
            <div class="button">北京</div>
          </div>
          <div class="button-wrapper">
            <div class="button">北京</div>
          </div>
          <div class="button-wrapper">
            <div class="button">北京</div>
          </div>
          <div class="button-wrapper">
            <div class="button">北京</div>
          </div>
        </div>
      </div>
      <div class="area">
        <div class="title area-color">热门城市</div>
        <div class="button-list">
          <div class="button-wrapper" v-for="item in hot" :key="item.id">
            <div class="button">{{item.name}}</div>
          </div>
        </div>
      </div>
      <div class="area" v-for="(item,key) of cities" :key="key" :ref="key">
        <div class="title area-color">{{key}}</div>
        <div class="item-list">
          <div class="item" v-for="innerItem of item" :key="innerItem.id">{{innerItem.name}}</div> 
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Bscroll from "better-scroll";
import {mapGetters} from 'vuex'
export default {
  name: "list",
  props:{
    cities:{
      type:Object
    },
    hot:{
      type:Array
    }
  },
  computed: {
    ...mapGetters('citiesAlp',['watchCitiesAlp'])
  },
  watch:{
    watchCitiesAlp(nv,ov){
     if(nv){
        const element = this.$refs[nv][0];
        this.scroll.scrollToElement(element,800);
    }
    }
  },
  data() {
    return {
    };
  },
  methods: {
    aa(){
      console.log(11111)
      console.log("this.watchCitiesAlp===>",this.watchCitiesAlp);
    }
  },
  mounted() {
    this.scroll = new Bscroll(this.$refs.wrapper);
  }
};
</script>
<style lang="stylus" scoped>
@import '~@/assets/common/commonstyl/common.styl';

.list {
  position: absolute;
  top: 154px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;

  .area {
    .title {
      line-height: 40px;
      background-color: #eee;
      padding-left: 20px;
      color: #666;
      font-size: 26px;
      border-top: 1px solid #ccc;
      border-bottom: 1px solid #ccc;
    }

    .button-list {
      overflow: hidden;
      padding: 10px 60px 10px 10px;

      .button-wrapper {
        float: left;
        width: 33.33%;

        .button {
          margin: 10px;
          padding: 10px 0;
          text-align: center;
          border: 2px solid #ccc;
          border-radius: 10px;
        }
      }
    }

    .item-list {
      .item {
        line-height: 76px;
        padding-left: 20px;
        border-bottom: 1px solid #ccc;
      }
    }
  }
}
</style>